﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using lc = Microsoft.Phone.Tasks;

namespace Utility
{
    public partial class Call191Page : PhoneApplicationPage
    {
        private string phoneNumber;
        private string displayName;
        public Call191Page()
        {
            InitializeComponent();
            phoneNumber = "191";
            displayName = "Police";
            
            openPhoneNumberBtn.Click += openPhoneNumberBtn_Click;
           
        }

        void openPhoneNumberBtn_Click(object sender, RoutedEventArgs e)
        {
            lc.PhoneNumberChooserTask phonenum = new lc.PhoneNumberChooserTask();
            phonenum.Completed += phonenum_Completed;
            phonenum.Show();
        }

        void phonenum_Completed(object sender, lc.PhoneNumberResult e)
        {
            if (e.TaskResult == lc.TaskResult.OK) {
                this.phoneNumber = e.PhoneNumber;
                this.displayName = e.DisplayName;
                phoneNumberTxt.Text = e.PhoneNumber;
            }
        }

       

        private void callBtn_Click(object sender, RoutedEventArgs e)
        {
            lc.PhoneCallTask call = new lc.PhoneCallTask();
            call.DisplayName = displayName;
            call.PhoneNumber = phoneNumber;
            call.Show();
        }
    }
}